#include "BoxMenu.h"
#include "StageLayer.h"
#include "GameScene.h"

using namespace cocos2d;

CCScene *BoxMenu::scene()
{
    CCScene *scene = CCScene::create();
    BoxMenu *layer = BoxMenu::create();
    scene->addChild(layer);
    
    return scene;    
}

bool BoxMenu::init()
{
    if(!CCLayer::init())
    {
//        return false;
    }
    CCMenu *menu = this->getBoxMenu();
    this->addChild(menu);
    
    return true;
}

CCMenu *BoxMenu::getBoxMenu()
{
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    
    CCMenuItem *newGame = CCMenuItemFont::create("New Game", this, menu_selector(BoxMenu::newGame));
    CCMenuItem *setStage = CCMenuItemFont::create("Select Stage", this, menu_selector(BoxMenu::selectStage));
    
    CCMenu *menu = CCMenu::create(newGame, setStage, NULL);
//    menu->setPosition(ccp(size.width/2, size.height/2));
    menu->alignItemsVertically();
    
    return menu;
}

void BoxMenu::newGame(CCObject* pSender)
{
    CCDirector::sharedDirector()->replaceScene(GameScene::sceneWithStage(1));
}

void BoxMenu::selectStage(CCObject* pSender)
{
    CCDirector::sharedDirector()->replaceScene(StageLayer::scene());
}


